package cn.edu.tju.elm.repository;

import cn.edu.tju.elm.model.Cart;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface CartRepository extends JpaRepository<Cart, Long> {

    // 根据用户ID查询购物车项列表
    List<Cart> findByCustomerId(Long customerId);

    // 根据用户ID和商品ID查询购物车项
    Optional<Cart> findByCustomerIdAndFoodId(Long customerId, Long foodId);

    // 根据用户ID删除购物车项
    void deleteByCustomerIdAndFoodId(Long customerId, Long foodId);

    // 根据ID和用户ID查询购物车项
    Optional<Cart> findByIdAndCustomerId(Long id, Long customerId);

    // 根据用户ID和商家ID查询购物车项
    List<Cart> findByCustomerIdAndBusinessId(Long customerId, Long businessId);
}